import apiType, {
    GET_RECHARGE_WECHAT_ACCOUNT_LIST,
    GET_RECHARGE_ALIPAY_ACCOUNT_LIST,
    GET_WECHAT_PAY_APPLY,
    GET_ALIPAY_APPLY,
    PAY_CONFIG_STORE,
    GET_PAYMENT_GLOBAL_CONFIG
} from "@constants/ActionTypes";

const initialState = {
    rechargeWechatAccount: {}, // 微信收款账户
    rechargeAlipayAccount: {}, // 支付宝收款账户
    wechatApplyDetail: {}, // 微信收款账户详情
    alipayApplyDetail: {}, // 支付宝收款账户详情
    payConfigStoreList: {}, // 收款配置
    payGlobalConfig: {}, // 全局收款配置
}

export default function update(state = initialState, action) {
    const { response, params, payload } = action
    switch (action.type) {
        case apiType(GET_RECHARGE_WECHAT_ACCOUNT_LIST).success:
            return {
                ...state,
                rechargeWechatAccount: response,
            }
        case apiType(GET_RECHARGE_ALIPAY_ACCOUNT_LIST).success:
            return {
                ...state,
                rechargeAlipayAccount: response,
            }
        case apiType(GET_WECHAT_PAY_APPLY).success:
            return {
                ...state,
                wechatApplyDetail: response,
            }
        case apiType(GET_ALIPAY_APPLY).success:
            return {
                ...state,
                alipayApplyDetail: response,
            }
        case apiType(PAY_CONFIG_STORE).success:
            return {
                ...state,
                payConfigStoreList: response,
            }
        case apiType(GET_PAYMENT_GLOBAL_CONFIG).success:
            return {
                ...state,
                payGlobalConfig: response,
            }
        default:
            return state
    }
}